Skip to content

Extras: the command feature, a command palette, Combobox and Autosuggest (#345) - #401

Merged
samitbasu merged 15 commits into
mainfrom
command-345
Nov 20, 2026
Merged

samitbasu merged 15 commits into
mainfrom
command-345

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Fixes #345. Built on #391, #397 (C1) and #400 (keys_from) (and so #381), which are merged in; this diff shows their changes until they land.

The look is provisional: it reuses the menu's item, heading and shortcut looks and the select's trigger. The 13 looks of the design note's §9 are in a render round, waiting for the user's pick (see the comment below). The UI also needs the user's own trial before this is approved: cargo xtask example command_palette (or cargo xtask web command_palette).

API for review (eggshell_ui_extras::command, feature command)

  • CommandExt on Builder:
    • command_list(key) -> CommandList: an inline search field over the matching items.
    • command_dialog(key, Open, on_close) -> CommandList: the same in a centred modal dialog. A pick runs the item, then on_close; so does a dismissal. The app opens it with a Menus and commands: trigger content, command items as chains, checked command items, run_with, per-menu width #325 command bound to Cmd/Ctrl+K, so the chord shows in menus and Web: keep the browser off chords an enabled command claims #357 keeps the browser off it.
    • combobox(key, Option<V>, impl IntoIterator<Item = (V, String)>) -> ComboboxChain (V: Key + Copy + PartialEq): a select-like trigger opening a popover with the list. The chosen option is checked; a pick runs on_change(app, V) and closes it.
    • autosuggest(key, &str, impl IntoIterator<Item = String>) -> AutosuggestChain: a text field with matching suggestions under it. The field's text is the value; a pick runs on_change(app, String).
  • CommandList methods: placeholder, named, filter, filtering, on_query, empty, classes, items(|items| ..).
  • Items methods:
  • ComboboxChain methods: placeholder, named, filter, empty, classes, on_change.
  • AutosuggestChain methods: placeholder, named, filter, filtering, classes, on_change.
  • The one filter:
    • word_prefix(query, Candidate { label, keywords }) -> Option<Score>: each query word must start a word of the label or of a keyword, case and accents aside. The start of the label ranks first, then a later word, then a keyword; ties keep the app's order.
    • Score::new(u32) / Score::BEST (lower ranks first), for an app's own filter.
    • Filtering::{Ours, App(Pending::{Settled, Loading})}: in App, the app filters itself (cmdk's shouldFilter={false}) and its items show as given.
  • Open::{Yes, No} (from bool).

Behaviour, per the decisions on #345

  • The library ships the word-prefix matcher, overridable with .filter, or skipped with Filtering::App (a pending state shows a loading row).
  • The first match is highlighted while typing in Command and Combobox, not in Autosuggest: there Enter stays the field's until the arrows move.
  • Results are in a virtual list driven from the field (core keys_from), not capped.
  • Groups come from the caller. A pick closes the palette and the combobox. Checked commands show their check and announce it.
  • Disabled commands are greyed, announced disabled, and passed by.
  • Escape closes the dialog and the combobox's popover, and puts an autosuggest's suggestions away until the next edit.

Accessibility

  • The search field is Role::ComboBox and owns the keys.
  • The results list is Role::ListBox; the field announces that it controls the list, and the highlighted row as its active descendant. Rows are ListBoxOption.
  • The dialog is a Dialog named by .named. The combobox trigger is a ComboBox with its value, has_popup = Dialog and expanded.
  • Known limit: group headings sit inside their first row (the virtual list's rows are all options), so a group is not announced as a Group.

Tests (tests/it/command_palette.rs, which drives the example, plus filter unit tests)

  • Ctrl+K opens the palette with its field focused and the first item highlighted.
  • Typing filters by word prefix and by keywords.
  • Nothing matching shows the empty state.
  • Enter picks the highlight and closes the palette.
  • A picked command runs.
  • A checked command says so, a disabled one is passed by, and Escape closes the palette.
  • The combobox opens, filters, picks, closes, and shows its value.
  • The autosuggest suggests with no highlight and takes a pick.
  • It shows nothing when nothing matches.
  • Escape puts its suggestions away until the next edit.

Dependency: unicode-normalization (optional, command feature), for accent folding.

Checks

🤖 Generated with Claude Code

samitbasu and others added 3 commits November 18, 2026 15:48
…est (#345)

The widgets of #345, in eggshell-ui-extras behind the `command` feature, on
core's public API (moving to the widgets crate with #366).

- `filter`: the one filter all three use. `word_prefix(query, Candidate)`:
  each query word must start a word of the label or of a hidden keyword,
  case and accents aside (Unicode decomposition, via
  `unicode-normalization`); the start of the label ranks before a later
  word, before a keyword; ties keep the app's order. An app overrides it
  with `.filter(|query, candidate| -> Option<Score>)`, or filters itself
  with `.filtering(Filtering::App(Pending::Loading | Pending::Settled))`
  and `.on_query(..)`.
- `CommandExt::command_list(key)`: a search field (`Role::ComboBox`) over
  the matching items in a virtual list it drives (`keys_from`), first
  match highlighted, with groups from the caller (`Items::group`,
  `Items::commands` for a #325 table), keywords, shortcuts, checks and
  disabled rows, and an empty state.
- `CommandExt::command_dialog(key, Open, on_close)`: the same list in a
  centred modal dialog; a pick runs the item, then closes it. The app opens
  it with a #325 command bound to Cmd/Ctrl+K, so it shows in menus and
  #357 keeps the browser off the chord.
- `CommandExt::combobox(key, Option<V>, options)`: a select-like trigger
  that opens a popover holding the list; the chosen option is checked, a
  pick runs `on_change` and closes it.
- `CommandExt::autosuggest(key, text, suggestions)`: a text field
  (`Role::ComboBox`) with matching suggestions under it, none highlighted
  until the arrows move, so Enter is still the field's; a pick or Escape
  puts them away until the next edit.

The look is provisional (the menu's item, heading and shortcut looks, the
select's trigger), pending the user's pick in the render round.

The `command_palette` example: a Ctrl+K palette over a command table and
a page list, a combobox and an autosuggest; its tests drive all three.

Part of #345.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
A focused text field keeps Escape from the overlay's dismissal, so the
autosuggest reads it from its own field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
@samitbasu

Copy link
Copy Markdown
Owner Author

Render round for #345's 13 looks

The sheet is at ~/Devel/bullseye-wt/command-candidates.png: Vega light, Vega dark and Lyra light, side by side, at 1×, rendered with testing::screenshot on lavapipe. The scratch that draws it is ~/Devel/bullseye-wt/command-candidates.rs. shadcn's own value is tagged [shadcn], and my recommendation is starred *. Nothing is final until you pick; the PR ships the menu's looks as a placeholder.

  1. Search field in Command. (a) no border, a search icon, a bottom rule, height 36 [shadcn] *; (b) a framed input inside the box; (c) a bottom rule with no icon.
  2. Row. (a) height 32, padding 8, the accent highlight [shadcn; the same as the menu item] *; (b) height 28; (c) height 36.
  3. Combobox's chosen mark. (a) a check after the label [shadcn now] *; (b) a check before the label [shadcn before]; (c) none.
  4. Group heading. (a) xs, medium weight, muted, with a separator between groups [shadcn] *; (b) the menu's label, no separator; (c) small caps.
  5. Empty state. (a) "No results found.", centred, padding 24 [shadcn] *; (b) muted and left-aligned; (c) muted, and naming the query. The wording is yours.
  6. Shortcut text. (a) xs, muted, widest tracking [shadcn CommandShortcut] *; (b) kbd chips.
  7. Match emphasis. (a) none [cmdk] *; (b) the match in bold; (c) the match tinted.
  8. Combobox trigger. (a) an outline button with chevrons-up-down [shadcn] *; (b) the select's trigger with one chevron, consistent with Dropdown: children in the trigger, a select's chevron, per-menu classes #354; (c) the select's trigger with chevrons-up-down. If the combobox should read as a select, (b) is the consistent choice.
  9. Popover width. (a) the trigger's width [shadcn example] *; (b) at least 288.
  10. The list's max height. (a) 300 [shadcn] *; (b) 240.
  11. CommandDialog. (a) centred, 512 wide, rounded-lg, with a scrim [shadcn Dialog] *; (b) high, 20% from the top; (c) 448 wide.
  12. Cmd/Ctrl+K hint on a search trigger. (a) a kbd chip at the end [shadcn docs] *; (b) muted "Ctrl+K" text; (c) none.
  13. Loading row. (a) a spinner and "Loading…", centred *; (b) text only [cmdk]. There is no "and N more" row, since you chose the virtual list. The wording is yours.

Before this is approved, please try it yourself: cargo xtask example command_palette (Ctrl+K, the combobox, and the city field).

🤖 Generated with Claude Code

@samitbasu

Copy link
Copy Markdown
Owner Author

Looks decided (user, 2026-11-19):

  • Looks 1–7 and 9–13: accepted as recommended, with the wording shown ("No results found.", "Loading…").
  • Look 8 and the combobox structure: the recommendation was wrong. It described shadcn's OLD combobox (a Popover + Command opened from an outline button with ChevronsUpDown). shadcn's current Combobox (registry/new-york-v4/ui/combobox.tsx, on Base UI) is an input group: you type in the trigger itself, with a ghost icon-xs ChevronDown button (muted, size-4) at the inline end, an optional clear × (showClear), and the list below (sideOffset 6, align start). Decision: rebuild combobox to the current shadcn design, reusing autosuggest's field→list wiring (Core: an open listbox announces controls and its active descendant on its anchor (C1 of #345) #397's relations sit on the field). command_list and command_dialog are unchanged.

From now on, render rounds must cite the current shadcn registry source file for each [shadcn] value, not memory.

samitbasu and others added 4 commits November 19, 2026 12:51
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
… current look

The combobox is rebuilt to shadcn's current Combobox (registry/bases/radix/ui
combobox.tsx): a field you type in, inside the select's box with the ring
while it has focus, a ghost icon-xs chevron at the end (a clear button in its
place while there is a value and `on_clear` is set), and the list below the
box, 6 pt apart and as wide as it, with no search field of its own. Typing
filters and opens it; a click, the chevron or ArrowDown opens it; Escape or a
press outside closes it and puts back the chosen label.

The list takes shadcn's current command look through a new CommandStyle
(installed by the shadcn preset): the highlighted row is bg-muted with
foreground text, the search group is h-8 rounded-lg with bg-input/30 and
border-input/30 inside a p-1 pb-0 wrapper, the list stops at max-h-72, a
group heading is muted text-xs, and a chosen mark sits after the label.

A scroll container is as tall as it is told, so a list built with only a
max height collapsed to nothing in a render; the list is now told what its
rows come to, up to the style's limit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
@samitbasu

Copy link
Copy Markdown
Owner Author

Design approved by the user from the renders (2026-11-19). That covers shadcn's current input-group combobox and the audit's changes: bg-muted selection, the h-8 rounded search group, max-h 288, muted headings, and the check after the label. Add: the list closes when focus Tabs away from the field (ARIA combobox). The "Show options" / "Clear" names stay TODO wording for the user. A hands-on trial follows before merge.

samitbasu and others added 2 commits November 19, 2026 15:43
cn-command-list and cn-combobox-list are no-scrollbar (style-vega.css:382,
325); the autosuggest shows the combobox's list. They use Tw::scrollbar_none,
so the rows are as wide as the box and no bar sits under the search field.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
samitbasu and others added 4 commits November 19, 2026 16:07
Scroll padding and the scrollbar class sit side by side on Tw.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
cn-command-list and cn-combobox-list are scroll-py-1 (style-vega.css:382,
325): the lists use Tw::scroll_py(1.0), so an arrow key never leaves the
highlighted row flush with the edge, under the search field.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AJYxo4YJZUXcPJ1bHdAHKy
@samitbasu

Copy link
Copy Markdown
Owner Author

Approved by the user after the trial, rebuilt to shadcn's current Combobox (2026-11-19). GitHub's required checks pass on the branch merged with current main. Merging.

@samitbasu
samitbasu merged commit 9aa3d6e into main Nov 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Combobox and Command palette (searchable pickers)

1 participant